home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1997 July: Mac OS SDK / Dev.CD Jul 97 SDK1.toast / Development Kits (Disc 1) / Interfaces&Libraries / Interfaces / PInterfaces / OSA.p < prev    next >
Encoding:
Text File  |  1995-07-06  |  52.3 KB  |  1,466 lines  |  [TEXT/MPS ]

  1. {
  2.      File:        OSA.p
  3.  
  4.      Contains:    AppleScript Client Interfaces.
  5.  
  6.      Version:    Technology:    AppleScript 1.1
  7.                  Package:    Universal Interfaces 2.1 in “MPW Latest” on ETO #18
  8.  
  9.      Copyright:    © 1984-1995 by Apple Computer, Inc.
  10.                  All rights reserved.
  11.  
  12.      Bugs?:        If you find a problem with this file, use the Apple Bug Reporter
  13.                  stack.  Include the file and version information (from above)
  14.                  in the problem description and send to:
  15.                      Internet:    apple.bugs@applelink.apple.com
  16.                      AppleLink:    APPLE.BUGS
  17.  
  18. }
  19.  
  20. {$IFC UNDEFINED UsingIncludes}
  21. {$SETC UsingIncludes := 0}
  22. {$ENDC}
  23.  
  24. {$IFC NOT UsingIncludes}
  25.  UNIT OSA;
  26.  INTERFACE
  27. {$ENDC}
  28.  
  29. {$IFC UNDEFINED __OSA__}
  30. {$SETC __OSA__ := 1}
  31.  
  32. {$I+}
  33. {$SETC OSAIncludes := UsingIncludes}
  34. {$SETC UsingIncludes := 1}
  35.  
  36.  
  37. {$IFC UNDEFINED __ERRORS__}
  38. {$I Errors.p}
  39. {$ENDC}
  40. {    ConditionalMacros.p                                            }
  41.  
  42. {$IFC UNDEFINED __APPLEEVENTS__}
  43. {$I AppleEvents.p}
  44. {$ENDC}
  45. {    Types.p                                                        }
  46. {    Memory.p                                                    }
  47. {        MixedMode.p                                                }
  48. {    OSUtils.p                                                    }
  49. {    Events.p                                                    }
  50. {        Quickdraw.p                                                }
  51. {            QuickdrawText.p                                        }
  52. {    EPPC.p                                                        }
  53. {        AppleTalk.p                                                }
  54. {        Files.p                                                    }
  55. {            Finder.p                                            }
  56. {        PPCToolbox.p                                            }
  57. {        Processes.p                                                }
  58. {    Notification.p                                                }
  59.  
  60. {$IFC UNDEFINED __AEOBJECTS__}
  61. {$I AEObjects.p}
  62. {$ENDC}
  63.  
  64. {$IFC UNDEFINED __COMPONENTS__}
  65. {$I Components.p}
  66. {$ENDC}
  67.  
  68. {$PUSH}
  69. {$ALIGN MAC68K}
  70. {$LibExport+}
  71.  
  72. CONST
  73.     kOSAComponentType            = 'osa ';
  74.  
  75. { 0x73637074 }
  76.     kOSAGenericScriptingComponentSubtype = 'scpt';
  77.  
  78. {    Type of script document files.    }
  79. { 0x6f736173 }
  80.     kOSAFileType                = 'osas';
  81.  
  82. {
  83.         Suite and event code of the RecordedText event. 
  84.         (See OSAStartRecording, below.)
  85.     }
  86. { 0x61736372 }
  87.     kOSASuite                    = 'ascr';
  88.  
  89. { 0x72656364 }
  90.     kOSARecordedText            = 'recd';
  91.  
  92. { Selector returns boolean }
  93. { 0x6d6f6469 }
  94.     kOSAScriptIsModified        = 'modi';
  95.  
  96. { Selector returns boolean }
  97. { 0x63736372 }
  98.     kOSAScriptIsTypeCompiledScript = 'cscr';
  99.  
  100. { Selector returns boolean }
  101. { 0x76616c75 }
  102.     kOSAScriptIsTypeScriptValue    = 'valu';
  103.  
  104. { Selector returns boolean }
  105. { 0x636e7478 }
  106.     kOSAScriptIsTypeScriptContext = 'cntx';
  107.  
  108. { Selector returns a DescType which may be passed to OSACoerceToDesc }
  109. { 0x62657374 }
  110.     kOSAScriptBestType            = 'best';
  111.  
  112. {
  113.         This selector is used to determine whether a script has source 
  114.         associated with it that when given to OSAGetSource, the call will not
  115.         fail.  The selector returns a boolean.
  116.     }
  117. { 0x67737263 }
  118.     kOSACanGetSource            = 'gsrc';
  119.  
  120.     typeOSADialectInfo            = 'difo';                        {  0x6469666f   }
  121.     keyOSADialectName            = 'dnam';                        {  0x646e616d   }
  122.     keyOSADialectCode            = 'dcod';                        {  0x64636f64   }
  123.     keyOSADialectLangCode        = 'dlcd';                        {  0x646c6364   }
  124.     keyOSADialectScriptCode        = 'dscd';
  125.  
  126.     
  127. TYPE
  128.     OSAError = ComponentResult;
  129.  
  130. { Under the Open Scripting Architecture all error results are longs }
  131.     OSAID = LONGINT;
  132.  
  133. {
  134.         OSAIDs allow transparent manipulation of scripts associated with
  135.          various scripting systems.
  136.     }
  137.  
  138. CONST
  139.     kOSANullScript                = 0;
  140.  
  141. { No -script constant. }
  142.     kOSANullMode                = 0;                            { sounds better }
  143.     kOSAModeNull                = 0;                            { tastes consistent }
  144.  
  145. {
  146.         Some routines take flags that control their execution.  This constant
  147.         declares default mode settings are used.
  148.     }
  149. TYPE
  150.     OSACreateAppleEventProcPtr = ProcPtr;  { FUNCTION OSACreateAppleEvent(theAEEventClass: AEEventClass; theAEEventID: AEEventID; (CONST)VAR target: AEAddressDesc; returnID: INTEGER; transactionID: LONGINT; VAR result: AppleEvent; refCon: LONGINT): OSErr; }
  151.     OSACreateAppleEventUPP = UniversalProcPtr;
  152.  
  153. CONST
  154.     uppOSACreateAppleEventProcInfo = $000FEFE0; { FUNCTION (4 byte param, 4 byte param, 4 byte param, 2 byte param, 4 byte param, 4 byte param, 4 byte param): 2 byte result; }
  155.  
  156. FUNCTION NewOSACreateAppleEventProc(userRoutine: OSACreateAppleEventProcPtr): OSACreateAppleEventUPP;
  157.     {$IFC NOT GENERATINGCFM }
  158.     INLINE $2E9F;
  159.     {$ENDC}
  160.  
  161. FUNCTION CallOSACreateAppleEventProc(theAEEventClass: AEEventClass; theAEEventID: AEEventID; {CONST}VAR target: AEAddressDesc; returnID: INTEGER; transactionID: LONGINT; VAR result: AppleEvent; refCon: LONGINT; userRoutine: OSACreateAppleEventUPP): OSErr;
  162.     {$IFC NOT GENERATINGCFM}
  163.     INLINE $205F, $4E90;
  164.     {$ENDC}
  165. TYPE
  166.     OSASendProcPtr = ProcPtr;  { FUNCTION OSASend((CONST)VAR theAppleEvent: AppleEvent; VAR reply: AppleEvent; sendMode: AESendMode; sendPriority: AESendPriority; timeOutInTicks: LONGINT; idleProc: AEIdleUPP; filterProc: AEFilterUPP; refCon: LONGINT): OSErr; }
  167.     OSASendUPP = UniversalProcPtr;
  168.  
  169. CONST
  170.     uppOSASendProcInfo = $003FEFE0; { FUNCTION (4 byte param, 4 byte param, 4 byte param, 2 byte param, 4 byte param, 4 byte param, 4 byte param, 4 byte param): 2 byte result; }
  171.  
  172. FUNCTION NewOSASendProc(userRoutine: OSASendProcPtr): OSASendUPP;
  173.     {$IFC NOT GENERATINGCFM }
  174.     INLINE $2E9F;
  175.     {$ENDC}
  176.  
  177. FUNCTION CallOSASendProc({CONST}VAR theAppleEvent: AppleEvent; VAR reply: AppleEvent; sendMode: AESendMode; sendPriority: AESendPriority; timeOutInTicks: LONGINT; idleProc: AEIdleUPP; filterProc: AEFilterUPP; refCon: LONGINT; userRoutine: OSASendUPP): OSErr;
  178.     {$IFC NOT GENERATINGCFM}
  179.     INLINE $205F, $4E90;
  180.     {$ENDC}
  181. {*************************************************************************
  182.     Standard Script Errors
  183. **************************************************************************
  184.     It is recommended that scripting components use the following set of error
  185.     codes to signal failure when applicable.  This enables applications that
  186.     use the OSA API to deal with some class of script errors in a less than 
  187.     ad hoc manner.  Scripting components are of course encouraged to return
  188.     component-specific errors when these don't apply.
  189. *************************************************************************}
  190. {        Dynamic errors:
  191.  
  192.     These errors result from data-dependent conditions and are typically
  193.     signaled at runtime.
  194. }
  195. {
  196.         Signaled when a value can't be coerced to the desired type. Similar
  197.           to errOSATypeError except results from coercion.
  198.     }
  199.  
  200. CONST
  201.     errOSACantCoerce            = errAECoercionFail;
  202.  
  203. { Signaled when an object is not found in a container }
  204.     errOSACantAccess            = errAENoSuchObject;
  205.  
  206. {
  207.         Signaled when an object cannot be set in a container.  Same as 
  208.           AERegistry error errAEWriteDenied.
  209.     }
  210.     errOSACantAssign            = -10006;
  211.  
  212. {
  213.         Signaled by user scripts or applications when no actual error code
  214.           is to be returned.  Simply means "an error has occurred".  Most useful
  215.           in conjunction with an error message from the application.
  216.     }
  217.     errOSAGeneralError            = -2700;
  218.  
  219. { Signaled when there is an attempt to divide by zero }
  220.     errOSADivideByZero            = -2701;
  221.  
  222. { Signaled when integer or real value is too large to be represented }
  223.     errOSANumericOverflow        = -2702;
  224.  
  225. {
  226.         Signaled when application can't be launched or when it is remote and
  227.           program linking is not enabled.
  228.     }
  229.     errOSACantLaunch            = -2703;
  230.  
  231. { Signaled when an application can't respond to AppleEvents }
  232.     errOSAAppNotHighLevelEventAware = -2704;
  233.  
  234. { Signaled when an application's terminology resource is not readable }
  235.     errOSACorruptTerminology    = -2705;
  236.  
  237. { Signaled when the runtime stack overflows }
  238.     errOSAStackOverflow            = -2706;
  239.  
  240. { Signaled when a runtime internal data structure overflows }
  241.     errOSAInternalTableOverflow    = -2707;
  242.  
  243. {
  244.         Signaled when an intrinsic limitation is exceeded for the size of 
  245.           a value or data structure.
  246.     }
  247.     errOSADataBlockTooLarge        = -2708;
  248.  
  249.     errOSACantGetTerminology    = -2709;
  250.  
  251.     errOSACantCreate            = -2710;
  252.  
  253. {        Component-specific dynamic script errors:
  254.  
  255.     The range -2720 thru -2739 is reserved for component-specific runtime errors.
  256.     (Note that error codes from different scripting components in this range will
  257.     overlap.)
  258. }
  259. {        Static errors:
  260.  
  261.     These errors comprise what are commonly thought of as parse and compile-
  262.     time errors.  However, in a dynamic system (e.g. AppleScript) any or all
  263.     of these may also occur at runtime.
  264. }
  265. { Signaled when data was not the right type and coercion is not allowed }
  266.     errOSATypeError                = errAEWrongDataType;
  267.  
  268. { Signaled when a message was sent to an object that didn't handle it }
  269.     OSAMessageNotUnderstood        = errAEEventNotHandled;
  270.  
  271. {
  272.         Signaled when a function to be returned doesn't exist.  (Probably only
  273.           useful in languages with first-class functions that distinguish between
  274.           functions and other values (two name spaces). This is different from
  275.           errOSAMessageNotUnderstood, which may be signaled when the method is
  276.           invoked.
  277.     }
  278.     OSAUndefinedHandler            = errAEHandlerNotFound;
  279.  
  280. { Signaled when a container can never have the requested object }
  281.     OSAIllegalAccess            = errAEAccessorNotFound;
  282.  
  283. { Signaled when index was out of range. Specialization of errOSACantAccess. }
  284.     OSAIllegalIndex                = errAEIllegalIndex;
  285.  
  286. { Signaled when a range is screwy. Specialization of errOSACantAccess. }
  287.     OSAIllegalRange                = errAEImpossibleRange;
  288.  
  289. {
  290.         Signaled when an object can never be set in a container.  Same as 
  291.           AERegistry error errAENotModifiable.
  292.     }
  293.     OSAIllegalAssign            = -10003;
  294.  
  295. {
  296.         Signaled when a syntax error occurs. (e.g. "Syntax error" or
  297.          "<this> can't go after <that>").
  298.     }
  299.     OSASyntaxError                = -2740;
  300.  
  301. {
  302.         Signaled when another form of syntax was expected. (e.g. "expected
  303.           a <type> but found <this>").
  304.     }
  305.     OSASyntaxTypeError            = -2741;
  306.  
  307. { Signaled when a name or number is too long to be parsed }
  308.     OSATokenTooLong                = -2742;
  309.  
  310. {
  311.         Signaled when a parameter is missing for a function invocation.  Note
  312.           that in some languages, this error may occur at runtime.
  313.     }
  314.     OSAMissingParameter            = errAEDescNotFound;
  315.  
  316. {
  317.         Signaled when function is called with the wrong number of parameters,
  318.           or a parameter pattern cannot be matched.
  319.     }
  320.     OSAParameterMismatch        = errAEWrongNumberArgs;
  321.  
  322. {
  323.         Signaled when a formal parameter, local variable, or instance variable
  324.           is specified more than once.
  325.     }
  326.     OSADuplicateParameter        = -2750;
  327.  
  328. {
  329.         Signaled when a formal parameter, local variable, or instance variable
  330.           is specified more than once.
  331.     }
  332.     OSADuplicateProperty        = -2751;
  333.  
  334. {
  335.         Signaled when more than one handler is defined with the same name in 
  336.           a scope where the language doesn't allow it.
  337.     }
  338.     OSADuplicateHandler            = -2752;
  339.  
  340. { Signaled when a variable is accessed that has no value }
  341.     OSAUndefinedVariable        = -2753;
  342.  
  343. {
  344.         Signaled when a variable is declared inconsistently in the same scope,
  345.           such as both local and global.
  346.     }
  347.     OSAInconsistentDeclarations    = -2754;
  348.  
  349. {
  350.         Signaled when illegal control flow occurs in an application (no catcher
  351.           for throw, non-lexical loop exit, etc.).
  352.     }
  353.     OSAControlFlowError            = -2755;
  354.  
  355. {        Component-specific static script errors:
  356.  
  357.     The range -2760 thru -2779 is reserved for component-specific parsing and
  358.     compile-time errors. (Note that error codes from different scripting
  359.     components in this range will overlap.)
  360. }
  361. {        Dialect-specific script errors:
  362.  
  363.     The range -2780 thru -2799 is reserved for dialect specific error codes for
  364.     scripting components that support dialects. (Note that error codes from
  365.     different scripting components in this range will overlap, as well as error
  366.     codes from different dialects in the same scripting component.)
  367. }
  368. {*************************************************************************
  369.     OSA Interface Descriptions
  370. **************************************************************************
  371.     The OSA Interface is broken down into a required interface, and several
  372.     optional interfaces to support additional functionality.  A given scripting
  373.     component may choose to support only some of the optional interfaces in
  374.     addition to the basic interface.  The OSA Component Flags may be used to 
  375.     query the Component Manager to find a scripting component with a particular
  376.     capability, or determine if a particular scripting component supports a 
  377.     particular capability.
  378. *************************************************************************}
  379. { OSA Component Flags: }
  380.     kOSASupportsCompiling        = $0002;
  381.     kOSASupportsGetSource        = $0004;
  382.     kOSASupportsAECoercion        = $0008;
  383.     kOSASupportsAESending        = $0010;
  384.     kOSASupportsRecording        = $0020;
  385.     kOSASupportsConvenience        = $0040;
  386.     kOSASupportsDialects        = $0080;
  387.     kOSASupportsEventHandling    = $0100;
  388.  
  389. { Component Selectors: }
  390.     kOSASelectLoad                = $0001;
  391.     kOSASelectStore                = $0002;
  392.     kOSASelectExecute            = $0003;
  393.     kOSASelectDisplay            = $0004;
  394.     kOSASelectScriptError        = $0005;
  395.     kOSASelectDispose            = $0006;
  396.     kOSASelectSetScriptInfo        = $0007;
  397.     kOSASelectGetScriptInfo        = $0008;
  398.     kOSASelectSetActiveProc        = $0009;
  399.     kOSASelectGetActiveProc        = $000A;
  400.  
  401. { Compiling: }
  402.     kOSASelectScriptingComponentName = $0102;
  403.     kOSASelectCompile            = $0103;
  404.     kOSASelectCopyID            = $0104;
  405.  
  406. { GetSource: }
  407.     kOSASelectGetSource            = $0201;
  408.  
  409. { AECoercion: }
  410.     kOSASelectCoerceFromDesc    = $0301;
  411.     kOSASelectCoerceToDesc        = $0302;
  412.  
  413. { AESending: }
  414.     kOSASelectSetSendProc        = $0401;
  415.     kOSASelectGetSendProc        = $0402;
  416.     kOSASelectSetCreateProc        = $0403;
  417.     kOSASelectGetCreateProc        = $0404;
  418.     kOSASelectSetDefaultTarget    = $0405;
  419.  
  420. { Recording: }
  421.     kOSASelectStartRecording    = $0501;
  422.     kOSASelectStopRecording        = $0502;
  423.  
  424. { Convenience: }
  425.     kOSASelectLoadExecute        = $0601;
  426.     kOSASelectCompileExecute    = $0602;
  427.     kOSASelectDoScript            = $0603;
  428.  
  429. { Dialects: }
  430.     kOSASelectSetCurrentDialect    = $0701;
  431.     kOSASelectGetCurrentDialect    = $0702;
  432.     kOSASelectAvailableDialects    = $0703;
  433.     kOSASelectGetDialectInfo    = $0704;
  434.     kOSASelectAvailableDialectCodeList = $0705;
  435.  
  436. { Event Handling: }
  437.     kOSASelectSetResumeDispatchProc = $0801;
  438.     kOSASelectGetResumeDispatchProc = $0802;
  439.     kOSASelectExecuteEvent        = $0803;
  440.     kOSASelectDoEvent            = $0804;
  441.     kOSASelectMakeContext        = $0805;
  442.  
  443. { scripting component specific selectors are added beginning with this value  }
  444.     kOSASelectComponentSpecificStart = $1001;
  445.  
  446. {        Mode Flags:
  447.  
  448.     Warning: These should not conflict with the AESend mode flags in
  449.     AppleEvents.h, because we may want to use them as OSA mode flags too.
  450. }
  451. {
  452.         This mode flag may be passed to OSALoad, OSAStore or OSACompile to
  453.           instruct the scripting component to not retain the "source" of an
  454.           expression.  This will cause the OSAGetSource call to return the error
  455.           errOSASourceNotAvailable if used.  However, some scripting components
  456.           may not retain the source anyway.  This is mainly used when either space
  457.           efficiency is desired, or a script is to be "locked" so that its
  458.           implementation may not be viewed.
  459.     }
  460.     kOSAModePreventGetSource    = $00000001;
  461.  
  462. {
  463.         These mode flags may be passed to OSACompile, OSAExecute, OSALoadExecute
  464.           OSACompileExecute, OSADoScript, OSAExecuteEvent, or OSADoEvent to
  465.           indicate whether or not the script may interact with the user, switch
  466.           layer or reconnect if necessary.  Any AppleEvents will be sent with the
  467.           corresponding AESend mode supplied.
  468.     }
  469.     kOSAModeNeverInteract        = kAENeverInteract;
  470.     kOSAModeCanInteract            = kAECanInteract;
  471.     kOSAModeAlwaysInteract        = kAEAlwaysInteract;
  472.     kOSAModeDontReconnect        = kAEDontReconnect;
  473.  
  474. {
  475.         This mode flag may be passed to OSACompile, OSAExecute, OSALoadExecute
  476.           OSACompileExecute, OSADoScript, OSAExecuteEvent, or OSADoEvent to
  477.           indicate whether or not AppleEvents should be sent with the
  478.           kAECanSwitchLayer mode flag sent or not. NOTE: This flag is exactly the
  479.           opposite sense of the AppleEvent flag kAECanSwitchLayer.  This is to
  480.           provide a more convenient default, i.e. not supplying any mode
  481.           (kOSAModeNull) means to send events with kAECanSwitchLayer.  Supplying
  482.           the kOSAModeCantSwitchLayer mode flag will cause AESend to be called
  483.           without kAECanSwitchLayer.
  484.     }
  485.     kOSAModeCantSwitchLayer        = $00000040;
  486.  
  487. {
  488.         This mode flag may be passed to OSACompile, OSAExecute, OSALoadExecute
  489.           OSACompileExecute, OSADoScript, OSAExecuteEvent, or OSADoEvent to
  490.           indicate whether or not AppleEvents should be sent with the kAEDontRecord
  491.           mode flag sent or not. NOTE: This flag is exactly the opposite sense of
  492.           the AppleEvent flag kAEDontRecord.  This is to provide a more convenient
  493.           default, i.e. not supplying any mode (kOSAModeNull) means to send events
  494.           with kAEDontRecord.  Supplying the kOSAModeDoRecord mode flag will 
  495.           cause AESend to be called without kAEDontRecord.
  496.     }
  497.     kOSAModeDoRecord            = $00001000;
  498.  
  499. {
  500.         This is a mode flag for OSACompile that indicates that a context should
  501.           be created as the result of compilation. All handler definitions are
  502.           inserted into the new context, and variables are initialized by
  503.           evaluating their initial values in a null context (i.e. they must be
  504.           constant expressions).
  505.     }
  506.     kOSAModeCompileIntoContext    = $00000002;
  507.  
  508. {
  509.         This is a mode flag for OSACompile that indicates that the previous
  510.           script ID (input to OSACompile) should be augmented with any new
  511.           definitions in the sourceData rather than replaced with a new script.
  512.           This means that the previous script ID must designate a context.
  513.           The presence of this flag causes the kOSAModeCompileIntoContext flag
  514.           to be implicitly used, causing any new definitions to be initialized
  515.           in a null context.
  516.     }
  517.     kOSAModeAugmentContext        = $00000004;
  518.  
  519. {
  520.         This mode flag may be passed to OSADisplay or OSADoScript to indicate
  521.           that output only need be human-readable, not re-compilable by OSACompile.
  522.           If used, output may be arbitrarily "beautified", e.g. quotes may be left
  523.           off of string values, long lists may have elipses, etc.
  524.     }
  525.     kOSAModeDisplayForHumans    = $00000008;
  526.  
  527. {
  528.         This mode flag may be passed to OSAStore in the case where the scriptID
  529.           is a context.  This causes the context to be saved, but not the context's
  530.           parent context.  When the stored context is loaded back in, the parent
  531.           will be kOSANullScript.
  532.     }
  533.     kOSAModeDontStoreParent        = $00010000;
  534.  
  535. {
  536.         This mode flag may be passed to OSAExecuteEvent to cause the event to
  537.           be dispatched to the direct object of the event. The direct object (or
  538.           subject attribute if the direct object is a non-object specifier) will
  539.           be resolved, and the resulting script object will be the recipient of
  540.           the message. The context argument to OSAExecuteEvent will serve as the
  541.           root of the lookup/resolution process.
  542.     }
  543.     kOSAModeDispatchToDirectObject = $00020000;
  544.  
  545. {
  546.         This mode flag may be passed to OSAExecuteEvent to indicate that
  547.           components do not have to get the data of object specifier arguments.
  548.     }
  549.     kOSAModeDontGetDataForArguments = $00040000;
  550.  
  551. {*************************************************************************
  552.     OSA Basic Scripting Interface
  553. **************************************************************************
  554.     Scripting components must at least support the Basic Scripting interface.
  555. *************************************************************************}
  556. {        Loading and Storing Scripts:
  557.  
  558.     These routines allow scripts to be loaded and stored in their internal
  559.     (possibly compiled, non-text) representation.
  560. }
  561. { Resource type for scripts }
  562.     kOSAScriptResourceType        = kOSAGenericScriptingComponentSubtype;
  563.  
  564. {
  565.         Default type given to OSAStore which creates "generic" loadable script
  566.           data descriptors.
  567.     }
  568.     typeOSAGenericStorage        = kOSAScriptResourceType;
  569.  
  570.  
  571. FUNCTION OSALoad(scriptingComponent: ComponentInstance; {CONST}VAR scriptData: AEDesc; modeFlags: LONGINT; VAR resultingScriptID: OSAID): OSAError;
  572.     {$IFC NOT GENERATINGCFM}
  573.     INLINE $2F3C, $C, $0001, $7000, $A82A;
  574.     {$ENDC}
  575. {
  576.         OSAComponentFunctionInline(kOSASelectLoad, 12);
  577.     
  578.         Errors:
  579.             badComponentInstance        invalid scripting component instance
  580.             errOSASystemError
  581.             errOSABadStorageType:        scriptData not for this scripting component
  582.             errOSACorruptData:            data seems to be corrupt
  583.             errOSADataFormatObsolete    script data format is no longer supported
  584.             errOSADataFormatTooNew        script data format is from a newer version
  585.         
  586.         ModeFlags:
  587.             kOSAModePreventGetSource
  588.     }
  589. FUNCTION OSAStore(scriptingComponent: ComponentInstance; scriptID: OSAID; desiredType: DescType; modeFlags: LONGINT; VAR resultingScriptData: AEDesc): OSAError;
  590.     {$IFC NOT GENERATINGCFM}
  591.     INLINE $2F3C, $10, $0002, $7000, $A82A;
  592.     {$ENDC}
  593. {
  594.         OSAComponentFunctionInline(kOSASelectStore, 16);
  595.     
  596.         Errors:
  597.             badComponentInstance    invalid scripting component instance
  598.             errOSASystemError
  599.             errOSAInvalidID
  600.             errOSABadStorageType:    desiredType not for this scripting component
  601.         
  602.         ModeFlags:
  603.             kOSAModePreventGetSource
  604.             kOSAModeDontStoreParent
  605.     }
  606. { Executing Scripts: }
  607. FUNCTION OSAExecute(scriptingComponent: ComponentInstance; compiledScriptID: OSAID; contextID: OSAID; modeFlags: LONGINT; VAR resultingScriptValueID: OSAID): OSAError;
  608.     {$IFC NOT GENERATINGCFM}
  609.     INLINE $2F3C, $10, $0003, $7000, $A82A;
  610.     {$ENDC}
  611. {
  612.         OSAComponentFunctionInline(kOSASelectExecute, 16);
  613.         This call runs a script.  The contextID represents the environment
  614.         with which global variables in the script are resolved.  The constant
  615.         kOSANullScript may be used for the contextID if the application wishes
  616.         to not deal with context directly (a default one is associated with each
  617.         scripting component instance).  The resultingScriptValueID is the 
  618.         result of evaluation, and contains a value which may be displayed using
  619.         the OSAGetSource call.  The modeFlags convey scripting component
  620.         specific information.
  621.     
  622.         Errors:
  623.             badComponentInstance    invalid scripting component instance
  624.             errOSASystemError
  625.             errOSAInvalidID
  626.             errOSAScriptError:        the executing script got an error
  627.     
  628.         ModeFlags:
  629.             kOSAModeNeverInteract
  630.             kOSAModeCanInteract
  631.             kOSAModeAlwaysInteract
  632.             kOSAModeCantSwitchLayer
  633.             kOSAModeDontReconnect
  634.             kOSAModeDoRecord
  635.     }
  636. { Displaying results: }
  637. FUNCTION OSADisplay(scriptingComponent: ComponentInstance; scriptValueID: OSAID; desiredType: DescType; modeFlags: LONGINT; VAR resultingText: AEDesc): OSAError;
  638.     {$IFC NOT GENERATINGCFM}
  639.     INLINE $2F3C, $10, $0004, $7000, $A82A;
  640.     {$ENDC}
  641. {
  642.         OSAComponentFunctionInline(kOSASelectDisplay, 16);
  643.         This call is used to convert results (script value IDs) into displayable
  644.         text. The desiredType should be at least typeChar, and modeFlags are
  645.         scripting system specific flags to control the formatting of the
  646.         resulting text. This call differs from OSAGetSource in that (1) it
  647.         always produces at least typeChar, (2) is only works on script values,
  648.         (3) it may display it's output in non-compilable form (e.g. without
  649.         string quotes, elipses inserted in long and/or circular lists, etc.) and
  650.         (4) it is required by the basic scripting interface.
  651.     
  652.         Errors:
  653.             badComponentInstance    invalid scripting component instance
  654.             errOSASystemError
  655.             errOSAInvalidID
  656.             errAECoercionFail:        desiredType not supported by scripting component
  657.     
  658.         ModeFlags:
  659.             kOSAModeDisplayForHumans
  660.     }
  661. { Getting Error Information: }
  662. FUNCTION OSAScriptError(scriptingComponent: ComponentInstance; selector: OSType; desiredType: DescType; VAR resultingErrorDescription: AEDesc): OSAError;
  663.     {$IFC NOT GENERATINGCFM}
  664.     INLINE $2F3C, $C, $0005, $7000, $A82A;
  665.     {$ENDC}
  666. {
  667.         OSAComponentFunctionInline(kOSASelectScriptError, 12);
  668.         Whenever script execution returns errOSAExecutionError, this routine
  669.         may be used to get information about that error.  The selector describes
  670.         the type of information desired about the error (various selectors are
  671.         listed below).  The desiredType indicates the data type of the result
  672.         desired for that selector.
  673.     
  674.         Errors:
  675.             badComponentInstance    invalid scripting component instance
  676.             errOSASystemError
  677.             errOSABadSelector:        selector not supported by scripting component
  678.             errAECoercionFail:        desiredType not supported by scripting component
  679.     }
  680. { OSAScriptError selectors: }
  681. {
  682.         This selector is used to determine the error number of a script error.
  683.         These error numbers may be either system error numbers, or error numbers
  684.         that are scripting component specific.
  685.         Required desiredTypes:    
  686.               typeShortInteger
  687.     }
  688.  
  689. CONST
  690.     kOSAErrorNumber                = keyErrorNumber;
  691.  
  692. {
  693.         This selector is used to determine the full error message associated
  694.         with the error number.  It should include the name of the application
  695.         which caused the error, as well as the specific error that occurred.
  696.         This selector is sufficient for simple error reporting (but see
  697.         kOSAErrorBriefMessage, below).
  698.         Required desiredTypes:
  699.             typeChar                    error message string
  700.     }
  701.     kOSAErrorMessage            = keyErrorString;
  702.  
  703. {
  704.         This selector is used to determine a brief error message associated with
  705.         the error number.  This message and should not mention the name of the
  706.         application which caused the error, any partial results or offending
  707.         object (see kOSAErrorApp, kOSAErrorPartialResult and
  708.         kOSAErrorOffendingObject, below).
  709.         Required desiredTypes:
  710.               typeChar                    brief error message string
  711.     }
  712. {  0x65727262  }
  713.     kOSAErrorBriefMessage        = 'errb';
  714.  
  715. {
  716.         This selector is used to determine which application actually got the
  717.         error (if it was the result of an AESend), or the current application
  718.         if ....
  719.         Required desiredTypes:
  720.               typeProcessSerialNumber        PSN of the errant application
  721.               typeChar                    name of the errant application
  722.     }
  723. {  0x65726170  }
  724.     kOSAErrorApp                = 'erap';
  725.  
  726. {
  727.         This selector is used to determine any partial result returned by an 
  728.         operation. If an AESend call failed, but a partial result was returned,
  729.         then the partial result may be returned as an AEDesc.
  730.         Required desiredTypes:
  731.               typeBest                    AEDesc of any partial result
  732.     }
  733. {  0x70746c72   }
  734.     kOSAErrorPartialResult        = 'ptlr';
  735.  
  736. {
  737.         This selector is used to determine any object which caused the error
  738.         that may have been indicated by an application.  The result is an 
  739.         AEDesc.
  740.         Required desiredTypes:
  741.               typeBest                    AEDesc of any offending object
  742.     }
  743. {  0x65726f62   }
  744.     kOSAErrorOffendingObject    = 'erob';
  745.  
  746. {
  747.         This selector is used to determine the type expected by a coercion 
  748.         operation if a type error occurred.
  749.     }
  750. {  0x65727274   }
  751.     kOSAErrorExpectedType        = 'errt';
  752.  
  753. {
  754.         This selector is used to determine the source text range (start and 
  755.         end positions) of where the error occurred.
  756.         Required desiredTypes:
  757.               typeOSAErrorRange
  758.     }
  759. {  0x65726e67  }
  760.     kOSAErrorRange                = 'erng';
  761.  
  762. {
  763.         An AERecord type containing keyOSASourceStart and keyOSASourceEnd fields
  764.         of type short.
  765.     }
  766. {  0x65726e67   }
  767.     typeOSAErrorRange            = 'erng';
  768.  
  769. { Field of a typeOSAErrorRange record of typeShortInteger }
  770. {  0x73726373    }
  771.     keyOSASourceStart            = 'srcs';
  772.  
  773. { Field of a typeOSAErrorRange record of typeShortInteger }
  774. {  0x73726365   }
  775.     keyOSASourceEnd                = 'srce';
  776.  
  777. { Disposing Script IDs: }
  778.  
  779. FUNCTION OSADispose(scriptingComponent: ComponentInstance; scriptID: OSAID): OSAError;
  780.     {$IFC NOT GENERATINGCFM}
  781.     INLINE $2F3C, $4, $0006, $7000, $A82A;
  782.     {$ENDC}
  783. {
  784.         OSAComponentFunctionInline(kOSASelectDispose, 4);
  785.         Disposes a script or context.
  786.     
  787.         Errors:
  788.             badComponentInstance    invalid scripting component instance
  789.             errOSASystemError
  790.             errOSAInvalidID
  791.     }
  792. { Getting and Setting Script Information: }
  793. FUNCTION OSASetScriptInfo(scriptingComponent: ComponentInstance; scriptID: OSAID; selector: OSType; value: LONGINT): OSAError;
  794.     {$IFC NOT GENERATINGCFM}
  795.     INLINE $2F3C, $C, $0007, $7000, $A82A;
  796.     {$ENDC}
  797. {
  798.         OSAComponentFunctionInline(kOSASelectSetScriptInfo, 12);
  799.     
  800.         Errors:
  801.             badComponentInstance    invalid scripting component instance
  802.             errOSASystemError
  803.             errOSAInvalidID
  804.             errOSABadSelector:        selector not supported by scripting component
  805.                                     or selector not for this scriptID
  806.     }
  807. FUNCTION OSAGetScriptInfo(scriptingComponent: ComponentInstance; scriptID: OSAID; selector: OSType; VAR result: LONGINT): OSAError;
  808.     {$IFC NOT GENERATINGCFM}
  809.     INLINE $2F3C, $C, $0008, $7000, $A82A;
  810.     {$ENDC}
  811. {
  812.         OSAComponentFunctionInline(kOSASelectGetScriptInfo, 12);
  813.     
  814.         Errors:
  815.             badComponentInstance    invalid scripting component instance
  816.             errOSASystemError
  817.             errOSAInvalidID
  818.             errOSABadSelector:        selector not supported by scripting component
  819.                                     or selector not for this scriptID
  820.     }
  821. { Manipulating the ActiveProc:
  822.  
  823.     Scripting systems will supply default values for these procedures if they
  824.     are not set by the client:
  825. }
  826. TYPE
  827.     OSAActiveProcPtr = ProcPtr;  { FUNCTION OSAActive(refCon: LONGINT): OSErr; }
  828.     OSAActiveUPP = UniversalProcPtr;
  829.  
  830. CONST
  831.     uppOSAActiveProcInfo = $000000E0; { FUNCTION (4 byte param): 2 byte result; }
  832.  
  833. FUNCTION NewOSAActiveProc(userRoutine: OSAActiveProcPtr): OSAActiveUPP;
  834.     {$IFC NOT GENERATINGCFM }
  835.     INLINE $2E9F;
  836.     {$ENDC}
  837.  
  838. FUNCTION CallOSAActiveProc(refCon: LONGINT; userRoutine: OSAActiveUPP): OSErr;
  839.     {$IFC NOT GENERATINGCFM}
  840.     INLINE $205F, $4E90;
  841.     {$ENDC}
  842.  
  843. FUNCTION OSASetActiveProc(scriptingComponent: ComponentInstance; activeProc: OSAActiveUPP; refCon: LONGINT): OSAError;
  844.     {$IFC NOT GENERATINGCFM}
  845.     INLINE $2F3C, $8, $0009, $7000, $A82A;
  846.     {$ENDC}
  847. {
  848.         OSAComponentFunctionInline(kOSASelectSetActiveProc, 8);
  849.         If activeProc is nil, the default activeProc is used.
  850.     
  851.         Errors:
  852.             badComponentInstance    invalid scripting component instance
  853.             errOSASystemError
  854.     }
  855. FUNCTION OSAGetActiveProc(scriptingComponent: ComponentInstance; VAR activeProc: OSAActiveUPP; VAR refCon: LONGINT): OSAError;
  856.     {$IFC NOT GENERATINGCFM}
  857.     INLINE $2F3C, $8, $000A, $7000, $A82A;
  858.     {$ENDC}
  859. {
  860.         OSAComponentFunctionInline(kOSASelectGetActiveProc, 8);
  861.     
  862.         Errors:
  863.             badComponentInstance    invalid scripting component instance
  864.             errOSASystemError
  865.     }
  866. {*************************************************************************
  867.     OSA Optional Compiling Interface
  868. **************************************************************************
  869.     Scripting components that support the Compiling interface have the 
  870.     kOSASupportsCompiling bit set in it's ComponentDescription.
  871. *************************************************************************}
  872. FUNCTION OSAScriptingComponentName(scriptingComponent: ComponentInstance; VAR resultingScriptingComponentName: AEDesc): OSAError;
  873.     {$IFC NOT GENERATINGCFM}
  874.     INLINE $2F3C, $4, $0102, $7000, $A82A;
  875.     {$ENDC}
  876. {
  877.         OSAComponentFunctionInline(kOSASelectScriptingComponentName, 4);
  878.         Given a scripting component, this routine returns the name of that
  879.         scripting component in a type that is coercable to text (typeChar).
  880.         The generic scripting component returns the name of the default
  881.         scripting component.  This name should be sufficient to convey to the
  882.         user the kind of script (syntax) he is expected to write.
  883.     
  884.         Errors:
  885.             badComponentInstance    invalid scripting component instance
  886.             errOSASystemError
  887.     }
  888. FUNCTION OSACompile(scriptingComponent: ComponentInstance; {CONST}VAR sourceData: AEDesc; modeFlags: LONGINT; VAR previousAndResultingScriptID: OSAID): OSAError;
  889.     {$IFC NOT GENERATINGCFM}
  890.     INLINE $2F3C, $C, $0103, $7000, $A82A;
  891.     {$ENDC}
  892. {
  893.         OSAComponentFunctionInline(kOSASelectCompile, 12);
  894.         Coerces input desc (possibly text) into a script's internal format.
  895.         Once compiled, the script is ready to run.  The modeFlags convey
  896.         scripting component specific information.  The previous script ID
  897.         (result parameter) is made to refer to the newly compiled script,
  898.         unless it was originally kOSANullScript.  In this case a new script
  899.         ID is created and used.
  900.     
  901.         Errors:
  902.             badComponentInstance    invalid scripting component instance
  903.             errOSASystemError
  904.             errAECoercionFail:        sourceData is not compilable
  905.             errOSAScriptError:        sourceData was a bad script (syntax error)
  906.             errOSAInvalidID:        previousAndResultingCompiledScriptID was not
  907.                                     valid on input
  908.     
  909.         ModeFlags:
  910.             kOSAModePreventGetSource
  911.             kOSAModeCompileIntoContext
  912.             kOSAModeAugmentContext
  913.             kOSAModeNeverInteract
  914.             kOSAModeCanInteract
  915.             kOSAModeAlwaysInteract
  916.             kOSAModeCantSwitchLayer
  917.             kOSAModeDontReconnect
  918.             kOSAModeDoRecord
  919.     }
  920. FUNCTION OSACopyID(scriptingComponent: ComponentInstance; fromID: OSAID; VAR toID: OSAID): OSAError;
  921.     {$IFC NOT GENERATINGCFM}
  922.     INLINE $2F3C, $8, $0104, $7000, $A82A;
  923.     {$ENDC}
  924. {
  925.         OSAComponentFunctionInline(kOSASelectCopyID, 8);
  926.         If toID is a reference to kOSANullScript then it is updated to have a
  927.         new scriptID value.  This call can be used to perform undo or revert
  928.         operations on scripts. 
  929.     
  930.         Errors:
  931.             badComponentInstance    invalid scripting component instance
  932.             errOSASystemError
  933.             errOSAInvalidID
  934.     }
  935. {*************************************************************************
  936.     OSA Optional GetSource Interface
  937. **************************************************************************
  938.     Scripting components that support the GetSource interface have the 
  939.     kOSASupportsGetSource bit set in it's ComponentDescription.
  940. *************************************************************************}
  941. FUNCTION OSAGetSource(scriptingComponent: ComponentInstance; scriptID: OSAID; desiredType: DescType; VAR resultingSourceData: AEDesc): OSAError;
  942.     {$IFC NOT GENERATINGCFM}
  943.     INLINE $2F3C, $C, $0201, $7000, $A82A;
  944.     {$ENDC}
  945. {
  946.         OSAComponentFunctionInline(kOSASelectGetSource, 12);
  947.         This routine causes a compiled script to be output in a form (possibly
  948.         text) such that it is suitable to be passed back to OSACompile.
  949.  
  950.         Errors:
  951.             badComponentInstance    invalid scripting component instance
  952.             errOSASystemError
  953.             errOSAInvalidID
  954.             errOSASourceNotAvailable    can't get source for this scriptID
  955.     }
  956. {*************************************************************************
  957.     OSA Optional AECoercion Interface
  958. **************************************************************************
  959.     Scripting components that support the AECoercion interface have the 
  960.     kOSASupportsAECoercion bit set in it's ComponentDescription.
  961. *************************************************************************}
  962. FUNCTION OSACoerceFromDesc(scriptingComponent: ComponentInstance; {CONST}VAR scriptData: AEDesc; modeFlags: LONGINT; VAR resultingScriptID: OSAID): OSAError;
  963.     {$IFC NOT GENERATINGCFM}
  964.     INLINE $2F3C, $C, $0301, $7000, $A82A;
  965.     {$ENDC}
  966. {
  967.         OSAComponentFunctionInline(kOSASelectCoerceFromDesc, 12);
  968.         This routine causes script data to be coerced into a script value.
  969.         If the scriptData is an AppleEvent, then the resultingScriptID is a
  970.         compiled script ID (mode flags for OSACompile may be used in this case).
  971.         Other scriptData descriptors create script value IDs.
  972.     
  973.         Errors:
  974.             badComponentInstance    invalid scripting component instance
  975.             errOSASystemError
  976.     
  977.         ModeFlags:
  978.             kOSAModePreventGetSource
  979.             kOSAModeCompileIntoContext
  980.             kOSAModeNeverInteract
  981.             kOSAModeCanInteract
  982.             kOSAModeAlwaysInteract
  983.             kOSAModeCantSwitchLayer
  984.             kOSAModeDontReconnect
  985.             kOSAModeDoRecord
  986.     }
  987. FUNCTION OSACoerceToDesc(scriptingComponent: ComponentInstance; scriptID: OSAID; desiredType: DescType; modeFlags: LONGINT; VAR result: AEDesc): OSAError;
  988.     {$IFC NOT GENERATINGCFM}
  989.     INLINE $2F3C, $10, $0302, $7000, $A82A;
  990.     {$ENDC}
  991. {
  992.         OSAComponentFunctionInline(kOSASelectCoerceToDesc, 16);
  993.         This routine causes a script value to be coerced into any desired form.
  994.         If the scriptID denotes a compiled script, then it may be coerced to 
  995.         typeAppleEvent.
  996.     
  997.         Errors:
  998.             badComponentInstance    invalid scripting component instance
  999.             errOSASystemError
  1000.             errOSAInvalidID
  1001.     }
  1002. {*************************************************************************
  1003.     OSA Optional AESending Interface
  1004. **************************************************************************
  1005.     Scripting components that support the AESending interface have the 
  1006.     kOSASupportsAESending bit set in it's ComponentDescription.
  1007. *************************************************************************}
  1008. {
  1009.     Scripting systems will supply default values for these procedures if they
  1010.     are not set by the client:
  1011. }
  1012. FUNCTION OSASetSendProc(scriptingComponent: ComponentInstance; sendProc: OSASendUPP; refCon: LONGINT): OSAError;
  1013.     {$IFC NOT GENERATINGCFM}
  1014.     INLINE $2F3C, $8, $0401, $7000, $A82A;
  1015.     {$ENDC}
  1016. {
  1017.         OSAComponentFunctionInline(kOSASelectSetSendProc, 8);
  1018.         If sendProc is nil, the default sendProc is used.
  1019.     
  1020.         Errors:
  1021.             badComponentInstance    invalid scripting component instance
  1022.             errOSASystemError
  1023.     }
  1024. FUNCTION OSAGetSendProc(scriptingComponent: ComponentInstance; VAR sendProc: OSASendUPP; VAR refCon: LONGINT): OSAError;
  1025.     {$IFC NOT GENERATINGCFM}
  1026.     INLINE $2F3C, $8, $0402, $7000, $A82A;
  1027.     {$ENDC}
  1028. {
  1029.         OSAComponentFunctionInline(kOSASelectGetSendProc, 8);
  1030.     
  1031.         Errors:
  1032.             badComponentInstance    invalid scripting component instance
  1033.             errOSASystemError
  1034.     }
  1035. FUNCTION OSASetCreateProc(scriptingComponent: ComponentInstance; createProc: OSACreateAppleEventUPP; refCon: LONGINT): OSAError;
  1036.     {$IFC NOT GENERATINGCFM}
  1037.     INLINE $2F3C, $8, $0403, $7000, $A82A;
  1038.     {$ENDC}
  1039. {
  1040.         OSAComponentFunctionInline(kOSASelectSetCreateProc, 8);
  1041.         If createProc is nil, the default createProc is used.
  1042.     
  1043.         Errors:
  1044.             badComponentInstance    invalid scripting component instance
  1045.             errOSASystemError
  1046.     }
  1047. FUNCTION OSAGetCreateProc(scriptingComponent: ComponentInstance; VAR createProc: OSACreateAppleEventUPP; VAR refCon: LONGINT): OSAError;
  1048.     {$IFC NOT GENERATINGCFM}
  1049.     INLINE $2F3C, $8, $0404, $7000, $A82A;
  1050.     {$ENDC}
  1051. {
  1052.         OSAComponentFunctionInline(kOSASelectGetCreateProc, 8);
  1053.     
  1054.         Errors:
  1055.             badComponentInstance    invalid scripting component instance
  1056.             errOSASystemError
  1057.     }
  1058. FUNCTION OSASetDefaultTarget(scriptingComponent: ComponentInstance; {CONST}VAR target: AEAddressDesc): OSAError;
  1059.     {$IFC NOT GENERATINGCFM}
  1060.     INLINE $2F3C, $4, $0405, $7000, $A82A;
  1061.     {$ENDC}
  1062. {
  1063.         OSAComponentFunctionInline(kOSASelectSetDefaultTarget, 4);
  1064.         This routine sets the default target application for AE sending.
  1065.         It also establishes the default target from which terminologies come.
  1066.         It is effectively like having an AppleScript "tell" statement around
  1067.         the entire program.  If this routine is not called, or if the target 
  1068.         is a null AEDesc, then the current application is the default target.
  1069.     
  1070.         Errors:
  1071.             badComponentInstance    invalid scripting component instance
  1072.             errOSASystemError
  1073.     }
  1074. {*************************************************************************
  1075.     OSA Optional Recording Interface
  1076. **************************************************************************
  1077.     Scripting components that support the Recording interface have the 
  1078.     kOSASupportsRecording bit set in it's ComponentDescription.
  1079. *************************************************************************}
  1080. FUNCTION OSAStartRecording(scriptingComponent: ComponentInstance; VAR compiledScriptToModifyID: OSAID): OSAError;
  1081.     {$IFC NOT GENERATINGCFM}
  1082.     INLINE $2F3C, $4, $0501, $7000, $A82A;
  1083.     {$ENDC}
  1084. {
  1085.         OSAComponentFunctionInline(kOSASelectStartRecording, 4);
  1086.         Starts recording.  If compiledScriptToModifyID is kOSANullScript, a
  1087.         new script ID is created and returned.  If the current application has
  1088.         a handler for the kOSARecordedText event, then kOSARecordedText events
  1089.         are sent to the application containing the text of each AppleEvent 
  1090.         recorded.
  1091.     
  1092.         Errors:
  1093.             badComponentInstance    invalid scripting component instance
  1094.             errOSASystemError
  1095.             errOSAInvalidID
  1096.             errOSARecordingIsAlreadyOn
  1097.     }
  1098. FUNCTION OSAStopRecording(scriptingComponent: ComponentInstance; compiledScriptID: OSAID): OSAError;
  1099.     {$IFC NOT GENERATINGCFM}
  1100.     INLINE $2F3C, $4, $0502, $7000, $A82A;
  1101.     {$ENDC}
  1102. {
  1103.         OSAComponentFunctionInline(kOSASelectStopRecording, 4);
  1104.         If compiledScriptID is not being recorded into or recording is not
  1105.         currently on, no error is returned.
  1106.     
  1107.         Errors:
  1108.             badComponentInstance    invalid scripting component instance
  1109.             errOSASystemError
  1110.             errOSAInvalidID
  1111.     }
  1112. {*************************************************************************
  1113.     OSA Optional Convenience Interface
  1114. **************************************************************************
  1115.     Scripting components that support the Convenience interface have the 
  1116.     kOSASupportsConvenience bit set in it's ComponentDescription.
  1117. *************************************************************************}
  1118. FUNCTION OSALoadExecute(scriptingComponent: ComponentInstance; {CONST}VAR scriptData: AEDesc; contextID: OSAID; modeFlags: LONGINT; VAR resultingScriptValueID: OSAID): OSAError;
  1119.     {$IFC NOT GENERATINGCFM}
  1120.     INLINE $2F3C, $10, $0601, $7000, $A82A;
  1121.     {$ENDC}
  1122. {
  1123.         OSAComponentFunctionInline(kOSASelectLoadExecute, 16);
  1124.         This routine is effectively equivalent to calling OSALoad followed by
  1125.         OSAExecute.  After execution, the compiled source is disposed.  Only the
  1126.         resulting value ID is retained.
  1127.     
  1128.         Errors:
  1129.             badComponentInstance        invalid scripting component instance
  1130.             errOSASystemError
  1131.             errOSABadStorageType:        scriptData not for this scripting component
  1132.             errOSACorruptData:            data seems to be corrupt
  1133.             errOSADataFormatObsolete    script data format is no longer supported
  1134.             errOSADataFormatTooNew        script data format is from a newer version
  1135.             errOSAInvalidID
  1136.             errOSAScriptError:            the executing script got an error
  1137.     
  1138.         ModeFlags:
  1139.             kOSAModeNeverInteract
  1140.             kOSAModeCanInteract
  1141.             kOSAModeAlwaysInteract
  1142.             kOSAModeCantSwitchLayer
  1143.             kOSAModeDontReconnect
  1144.             kOSAModeDoRecord
  1145.     }
  1146. FUNCTION OSACompileExecute(scriptingComponent: ComponentInstance; {CONST}VAR sourceData: AEDesc; contextID: OSAID; modeFlags: LONGINT; VAR resultingScriptValueID: OSAID): OSAError;
  1147.     {$IFC NOT GENERATINGCFM}
  1148.     INLINE $2F3C, $10, $0602, $7000, $A82A;
  1149.     {$ENDC}
  1150. {
  1151.         OSAComponentFunctionInline(kOSASelectCompileExecute, 16);
  1152.         This routine is effectively equivalent to calling OSACompile followed by
  1153.         OSAExecute.  After execution, the compiled source is disposed.  Only the
  1154.         resulting value ID is retained.
  1155.     
  1156.         Errors:
  1157.             badComponentInstance    invalid scripting component instance
  1158.             errOSASystemError
  1159.             errAECoercionFail:        sourceData is not compilable
  1160.             errOSAScriptError:        sourceData was a bad script (syntax error)
  1161.             errOSAInvalidID:        previousAndResultingCompiledScriptID was not
  1162.                                     valid on input
  1163.             errOSAScriptError:        the executing script got an error
  1164.     
  1165.         ModeFlags:
  1166.             kOSAModeNeverInteract
  1167.             kOSAModeCanInteract
  1168.             kOSAModeAlwaysInteract
  1169.             kOSAModeCantSwitchLayer
  1170.             kOSAModeDontReconnect
  1171.             kOSAModeDoRecord
  1172.     }
  1173. FUNCTION OSADoScript(scriptingComponent: ComponentInstance; {CONST}VAR sourceData: AEDesc; contextID: OSAID; desiredType: DescType; modeFlags: LONGINT; VAR resultingText: AEDesc): OSAError;
  1174.     {$IFC NOT GENERATINGCFM}
  1175.     INLINE $2F3C, $14, $0603, $7000, $A82A;
  1176.     {$ENDC}
  1177. {
  1178.         OSAComponentFunctionInline(kOSASelectDoScript, 20);
  1179.         This routine is effectively equivalent to calling OSACompile followed by
  1180.         OSAExecute and then OSADisplay.  After execution, the compiled source
  1181.         and the resulting value are is disposed.  Only the resultingText
  1182.         descriptor is retained.  If a script error occur during processing, the 
  1183.         resultingText gets the error message of the error, and errOSAScriptError
  1184.         is returned.  OSAScriptError may still be used to extract more 
  1185.         information about the particular error.
  1186.     
  1187.         Errors:
  1188.             badComponentInstance    invalid scripting component instance
  1189.             errOSASystemError
  1190.             errAECoercionFail:        sourceData is not compilable or 
  1191.                                     desiredType not supported by scripting component
  1192.             errOSAScriptError:        sourceData was a bad script (syntax error)
  1193.             errOSAInvalidID:        previousAndResultingCompiledScriptID was not
  1194.                                     valid on input
  1195.             errOSAScriptError:        the executing script got an error
  1196.     
  1197.         ModeFlags:
  1198.             kOSAModeNeverInteract
  1199.             kOSAModeCanInteract
  1200.             kOSAModeAlwaysInteract
  1201.             kOSAModeCantSwitchLayer
  1202.             kOSAModeDontReconnect
  1203.             kOSAModeDoRecord
  1204.             kOSAModeDisplayForHumans
  1205.     }
  1206. {*************************************************************************
  1207.     OSA Optional Dialects Interface
  1208. **************************************************************************
  1209.     Scripting components that support the Dialects interface have the 
  1210.     kOSASupportsDialects bit set in it's ComponentDescription.
  1211. *************************************************************************}
  1212. {
  1213.     These calls allows an scripting component that supports different dialects
  1214.     to dynamically switch between those dialects.  Although this interface is
  1215.     specified, the particular dialect codes are scripting component dependent.
  1216. }
  1217. FUNCTION OSASetCurrentDialect(scriptingComponent: ComponentInstance; dialectCode: INTEGER): OSAError;
  1218.     {$IFC NOT GENERATINGCFM}
  1219.     INLINE $2F3C, $2, $0701, $7000, $A82A;
  1220.     {$ENDC}
  1221. {
  1222.         OSAComponentFunctionInline(kOSASelectSetCurrentDialect, 2);
  1223.     
  1224.         Errors:
  1225.             badComponentInstance    invalid scripting component instance
  1226.             errOSASystemError
  1227.             errOSANoSuchDialect:    invalid dialectCode
  1228.     }
  1229. FUNCTION OSAGetCurrentDialect(scriptingComponent: ComponentInstance; VAR resultingDialectCode: INTEGER): OSAError;
  1230.     {$IFC NOT GENERATINGCFM}
  1231.     INLINE $2F3C, $4, $0702, $7000, $A82A;
  1232.     {$ENDC}
  1233. {
  1234.         OSAComponentFunctionInline(kOSASelectGetCurrentDialect, 4);
  1235.     
  1236.         Errors:
  1237.             badComponentInstance    invalid scripting component instance
  1238.             errOSASystemError
  1239.     }
  1240. FUNCTION OSAAvailableDialects(scriptingComponent: ComponentInstance; VAR resultingDialectInfoList: AEDesc): OSAError;
  1241.     {$IFC NOT GENERATINGCFM}
  1242.     INLINE $2F3C, $4, $0703, $7000, $A82A;
  1243.     {$ENDC}
  1244. {
  1245.         OSAComponentFunctionInline(kOSASelectAvailableDialects, 4);
  1246.         This call return an AEList containing information about each of the
  1247.         currently available dialects of a scripting component.  Each item
  1248.         is an AERecord of typeOSADialectInfo that contains at least the fields
  1249.         keyOSADialectName, keyOSADialectCode, KeyOSADialectLangCode and 
  1250.         keyOSADialectScriptCode.
  1251.     
  1252.         Errors:
  1253.             badComponentInstance    invalid scripting component instance
  1254.             errOSASystemError
  1255.     }
  1256. FUNCTION OSAGetDialectInfo(scriptingComponent: ComponentInstance; dialectCode: INTEGER; selector: OSType; VAR resultingDialectInfo: AEDesc): OSAError;
  1257.     {$IFC NOT GENERATINGCFM}
  1258.     INLINE $2F3C, $A, $0704, $7000, $A82A;
  1259.     {$ENDC}
  1260. {
  1261.         OSAComponentFunctionInline(kOSASelectGetDialectInfo, 10);
  1262.         This call gives information about the specified dialect of a scripting
  1263.         component. It returns an AEDesc whose type depends on the selector 
  1264.         specified. Available selectors are the same as the field keys for a
  1265.         dialect info record. The type of AEDesc returned is the same as the 
  1266.         type of the field that has same key as the selector.
  1267.     
  1268.         Errors:
  1269.             badComponentInstance    invalid scripting component instance
  1270.             errOSASystemError
  1271.              errOSABadSelector
  1272.             errOSANoSuchDialect:    invalid dialectCode
  1273.     }
  1274. FUNCTION OSAAvailableDialectCodeList(scriptingComponent: ComponentInstance; VAR resultingDialectCodeList: AEDesc): OSAError;
  1275.     {$IFC NOT GENERATINGCFM}
  1276.     INLINE $2F3C, $4, $0705, $7000, $A82A;
  1277.     {$ENDC}
  1278. {
  1279.         OSAComponentFunctionInline(kOSASelectAvailableDialectCodeList, 4);
  1280.         This is alternative to OSAGetAvailableDialectCodeList. Use this call
  1281.         and  OSAGetDialectInfo to get information on dialects.
  1282.         This call return an AEList containing dialect code for each of the
  1283.         currently available dialects of a scripting component. Each dialect
  1284.         code is a short integer of type typeShortInteger.
  1285.     
  1286.         Errors:
  1287.             badComponentInstance    invalid scripting component instance
  1288.             errOSASystemError
  1289.  
  1290.         Type of a dialect info record containing at least keyOSADialectName
  1291.         and keyOSADialectCode fields.
  1292.  
  1293.         keys for dialect info record, also used as selectors to OSAGetDialectInfo.
  1294.  
  1295.         Field of a typeOSADialectInfo record of typeChar.
  1296.         Field of a typeOSADialectInfo record of typeShortInteger.
  1297.         Field of a typeOSADialectInfo record of typeShortInteger.
  1298.         Field of a typeOSADialectInfo record of typeShortInteger.
  1299.     }
  1300. {*************************************************************************
  1301.     OSA Optional Event Handling Interface
  1302. **************************************************************************
  1303.     Scripting components that support the Event Handling interface have the 
  1304.     kOSASupportsEventHandling bit set in it's ComponentDescription.
  1305. *************************************************************************}
  1306. FUNCTION OSASetResumeDispatchProc(scriptingComponent: ComponentInstance; resumeDispatchProc: AEEventHandlerUPP; refCon: LONGINT): OSAError;
  1307.     {$IFC NOT GENERATINGCFM}
  1308.     INLINE $2F3C, $8, $0801, $7000, $A82A;
  1309.     {$ENDC}
  1310. {
  1311.         OSAComponentFunctionInline(kOSASelectSetResumeDispatchProc, 8);
  1312.         This function is used to set the ResumeDispatchProc that will be used
  1313.         by OSAExecuteEvent and OSADoEvent if either no event handler can be
  1314.         found in the context, or the context event hander "continues" control
  1315.         onward. The two constants kOSAUseStandardDispatch and kOSANoDispatch
  1316.         may also be passed to this routine indicating that the handler registered
  1317.         in the application with AEInstallEventHandler should be used, or no
  1318.         dispatch should occur, respectively.
  1319.     
  1320.         Errors:
  1321.             badComponentInstance    invalid scripting component instance
  1322.             errOSASystemError
  1323.     }
  1324.  
  1325. CONST
  1326.     kOSAUseStandardDispatch        = kAEUseStandardDispatch;
  1327.  
  1328. {
  1329.         Special ResumeDispatchProc constant which may be passed to 
  1330.         OSASetResumeDispatchProc indicating that the handler registered
  1331.         in the application with AEInstallEventHandler should be used.
  1332.         
  1333.         NOTE:    Had to remove the cast (AEEventHandlerUPP).  The C compiler
  1334.                 doesn't allow pointer types to be assigned to an enum.  All
  1335.                 constants must be assigned as enums to translate properly to
  1336.                 Pascal.
  1337.     }
  1338.     kOSANoDispatch                = kAENoDispatch;
  1339.  
  1340. {
  1341.         Special ResumeDispatchProc constant which may be passed to 
  1342.         OSASetResumeDispatchProc indicating that no dispatch should occur.
  1343.         
  1344.         NOTE:    Had to remove the cast (AEEventHandlerUPP).  The C compiler
  1345.                 doesn't allow pointer types to be assigned to an enum.  All
  1346.                 constants must be assigned as enums to translate properly to
  1347.                 Pascal.
  1348.     }
  1349.     kOSADontUsePhac                = $0001;
  1350.  
  1351. {
  1352.         Special refCon constant that may be given to OSASetResumeDispatchProc
  1353.         only when kOSAUseStandardDispatch is used as the ResumeDispatchProc.
  1354.         This causes the standard dispatch to be performed, except the phac
  1355.         handler is not called.  This is useful during tinkerability, when
  1356.         the phac handler is used to lookup a context associated with an event's 
  1357.         direct parameter, and call OSAExecuteEvent or OSADoEvent.  Failure to
  1358.         bypass the phac handler would result in an infinite loop.
  1359.     }
  1360.  
  1361. FUNCTION OSAGetResumeDispatchProc(scriptingComponent: ComponentInstance; VAR resumeDispatchProc: AEEventHandlerUPP; VAR refCon: LONGINT): OSAError;
  1362.     {$IFC NOT GENERATINGCFM}
  1363.     INLINE $2F3C, $8, $0802, $7000, $A82A;
  1364.     {$ENDC}
  1365. {
  1366.         OSAComponentFunctionInline(kOSASelectGetResumeDispatchProc, 8);
  1367.         Returns the registered ResumeDispatchProc.  If no ResumeDispatchProc has
  1368.         been registered, then kOSAUseStandardDispatch (the default) is returned.
  1369.     
  1370.         Errors:
  1371.             badComponentInstance    invalid scripting component instance
  1372.             errOSASystemError
  1373.     }
  1374. FUNCTION OSAExecuteEvent(scriptingComponent: ComponentInstance; {CONST}VAR theAppleEvent: AppleEvent; contextID: OSAID; modeFlags: LONGINT; VAR resultingScriptValueID: OSAID): OSAError;
  1375.     {$IFC NOT GENERATINGCFM}
  1376.     INLINE $2F3C, $10, $0803, $7000, $A82A;
  1377.     {$ENDC}
  1378. {
  1379.         OSAComponentFunctionInline(kOSASelectExecuteEvent, 16);
  1380.         This call is similar to OSAExecute except the initial command to
  1381.         execute comes in the form of an AppleEvent.  If the contextID
  1382.         defines any event handlers for that event, they are used to process
  1383.         the event.  If no event handler can be found in the context
  1384.         errAEEventNotHandled is returned.  If an event handler is found and
  1385.         the hander "continues" control onward, the ResumeDispatchProc
  1386.         (registered with OSASetResumeDispatchProc, above) is called given the
  1387.         AppleEvent.  The result is returned as a scriptValueID.
  1388.     
  1389.         Errors:
  1390.             badComponentInstance    invalid scripting component instance
  1391.             errOSASystemError
  1392.             errOSAInvalidID
  1393.             errOSAScriptError:        the executing script got an error
  1394.             errAEEventNotHandled:    no handler for event in contextID
  1395.     
  1396.         ModeFlags:
  1397.             kOSAModeNeverInteract
  1398.             kOSAModeCanInteract
  1399.             kOSAModeAlwaysInteract
  1400.             kOSAModeCantSwitchLayer
  1401.             kOSAModeDontReconnect
  1402.             kOSAModeDoRecord
  1403.     }
  1404. FUNCTION OSADoEvent(scriptingComponent: ComponentInstance; {CONST}VAR theAppleEvent: AppleEvent; contextID: OSAID; modeFlags: LONGINT; VAR reply: AppleEvent): OSAError;
  1405.     {$IFC NOT GENERATINGCFM}
  1406.     INLINE $2F3C, $10, $0804, $7000, $A82A;
  1407.     {$ENDC}
  1408. {
  1409.         OSAComponentFunctionInline(kOSASelectDoEvent, 16);
  1410.         This call is similar to OSADoScript except the initial command to
  1411.         execute comes in the form of an AppleEvent, and the result is an 
  1412.         AppleEvent reply record.  If the contextID defines any event handlers
  1413.         for that event, they are used to process the event.  If no event handler
  1414.         can be found in the context errAEEventNotHandled is returned.  If an
  1415.         event handler is found and the hander "continues" control onward, the
  1416.         ResumeDispatchProc (registered with OSASetResumeDispatchProc, above) is
  1417.         called given the AppleEvent.  The result is returned in the form of an
  1418.         AppleEvent reply descriptor. If at any time the script gets an error, or
  1419.         if the ResumeDispatchProc returns a reply event indicating an error,
  1420.         then the OSADoEvent call itself returns an error reply (i.e. OSADoEvent
  1421.         should never return errOSAScriptError).  Any error result returned by
  1422.         the ResumeDispatchProc will be returned by OSADoEvent.
  1423.     
  1424.         Errors:
  1425.             badComponentInstance    invalid scripting component instance
  1426.             errOSASystemError
  1427.             errOSAInvalidID
  1428.             errAEEventNotHandled:    no handler for event in contextID
  1429.     
  1430.         ModeFlags:
  1431.             kOSAModeNeverInteract
  1432.             kOSAModeCanInteract
  1433.             kOSAModeAlwaysInteract
  1434.             kOSAModeCantSwitchLayer
  1435.             kOSAModeDontReconnect
  1436.             kOSAModeDoRecord
  1437.     }
  1438. FUNCTION OSAMakeContext(scriptingComponent: ComponentInstance; {CONST}VAR contextName: AEDesc; parentContext: OSAID; VAR resultingContextID: OSAID): OSAError;
  1439.     {$IFC NOT GENERATINGCFM}
  1440.     INLINE $2F3C, $C, $0805, $7000, $A82A;
  1441.     {$ENDC}
  1442. {
  1443.         OSAComponentFunctionInline(kOSASelectMakeContext, 12);
  1444.         Makes a new empty context which may be passed to OSAExecute or 
  1445.         OSAExecuteEvent.  If contextName is typeNull, an unnamed context is
  1446.         created. If parentContext is kOSANullScript then the resulting context
  1447.         does not inherit bindings from any other context.
  1448.     
  1449.         Errors:
  1450.             badComponentInstance    invalid scripting component instance
  1451.             errOSASystemError
  1452.             errOSAInvalidID
  1453.             errAECoercionFail:        contextName is invalid
  1454.     }
  1455.  
  1456. {$ALIGN RESET}
  1457. {$POP}
  1458.  
  1459. {$SETC UsingIncludes := OSAIncludes}
  1460.  
  1461. {$ENDC} {__OSA__}
  1462.  
  1463. {$IFC NOT UsingIncludes}
  1464.  END.
  1465. {$ENDC}
  1466.